package com.pomr.model.equipmentstorage;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.pomr.model.synthesize.Manufacturer;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @作者：Administrator
 * @时间：22:08 2018/9/12 0012
 * @用途：库存调拨记录
 **/
@Entity
@Table(name="allocation_message")
public class AllocationMessage implements Serializable {
    @Id
    //配置uuid，本来jpa是不支持uuid的，但借用hibernate的方法可以实现。
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    private String id;
    @Column(name="equipment_id")
    private Integer equipmentId;//设备id
    @Column(name="equipment_name",length = 50)
    private String equipmentName;//设备名称
    @Column(name="especification" ,length = 20)
    private String especification;//设备型号
    @Column(name="manufacturer_id")
    private Integer manufacturerId;//厂商主键
    @Column(name="manufacturer_name",length = 50)
    private String manufacturerName;//厂商名称
    @Column(name="old_agency_id")
    private Integer oldAgencyId;//原机构
    @Column(name="new_agency_id")
    private Integer newAgencyId;//目标机构
    @Column(name="create_user")
    private Integer createUserId;//操作用户
    @JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd")
    @Column(name="create_time")
    private Date createTime;//创建时间
    @Column(name="num")
    private Integer num;//调拨数量
    @Formula("(select oag.name from agency oag where oag.id=old_agency_id)")
    private String oldAgencyName;//原机构名称
    @Formula("(select nag.name from agency nag where nag.id=new_agency_id)")
    private String newAgencyName;//目标机构名称
    @Formula("(select u.name from user u where u.id=create_user)")
    private String createUserName;//操作用户名称

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getEquipmentId() {
        return equipmentId;
    }

    public void setEquipmentId(Integer equipmentId) {
        this.equipmentId = equipmentId;
    }

    public String getEquipmentName() {
        return equipmentName;
    }

    public void setEquipmentName(String equipmentName) {
        this.equipmentName = equipmentName;
    }

    public String getEspecification() {
        return especification;
    }

    public void setEspecification(String especification) {
        this.especification = especification;
    }

    public Integer getManufacturerId() {
        return manufacturerId;
    }

    public void setManufacturerId(Integer manufacturerId) {
        this.manufacturerId = manufacturerId;
    }

    public String getManufacturerName() {
        return manufacturerName;
    }

    public void setManufacturerName(String manufacturerName) {
        this.manufacturerName = manufacturerName;
    }

    public Integer getOldAgencyId() {
        return oldAgencyId;
    }

    public void setOldAgencyId(Integer oldAgencyId) {
        this.oldAgencyId = oldAgencyId;
    }

    public Integer getNewAgencyId() {
        return newAgencyId;
    }

    public void setNewAgencyId(Integer newAgencyId) {
        this.newAgencyId = newAgencyId;
    }

    public Integer getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(Integer createUserId) {
        this.createUserId = createUserId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }


    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public String getOldAgencyName() {
        return oldAgencyName;
    }

    public void setOldAgencyName(String oldAgencyName) {
        this.oldAgencyName = oldAgencyName;
    }

    public String getNewAgencyName() {
        return newAgencyName;
    }

    public void setNewAgencyName(String newAgencyName) {
        this.newAgencyName = newAgencyName;
    }

    public String getCreateUserName() {
        return createUserName;
    }

    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
}
